// 1.加载mysql
const mysql = require('mysql')

// 2.创建连接
const coon = mysql.createConnection({
  host:'localhost',
  port: 3306,
  user: 'root',
  password: 'root',
  database: 'tj2'
})

// 3.连接到服务器
coon.connect()

// 4.完成增删改查
let sql = 'update student set age = ? where name = ?'
coon.query(sql, [19, '顿健康'] , (err, result)=>{
  if (err === null){
    console.log(result);
  } else {
    console.log(err);
  }
})

// 5.关闭连接
coon.end()